// -----------------------------------------------------------------------
//  <copyright file="ValidateCodeSetting.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://www.dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024-05-28 12:05</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Identity.Properties;
using DaprPlus.Settings;


namespace DaprPlus.Identity.Domain.Entities;

public class ValidateCodeSetting : ISetting
{
    public SettingItem<int> EmailCodeSeconds { get; set; } = new("ValidateCodeSetting:EmailCodeSeconds", 30 * 60);

    public SettingItem<int> SmsCodeSeconds { get; set; } = new("ValidateCodeSetting:SmsCodeSeconds", 10 * 60);

    public SettingItem<int> EmailMaxFailCount { get; set; } = new("ValidateCodeSetting:EmailMaxFailCount", 5);

    public SettingItem<int> SmsMaxFailCount { get; set; } = new("ValidateCodeSetting:SmsMaxFailCount", 3);

    /// <summary>
    /// 邮件验证码消息格式
    /// </summary>
    /// <returns></returns>
    public SettingItem<string> EmailCodeMessageFormat { get; set; } = new("ValidateCodeSetting:EmailCodeMessageFormat", GetEmailCodeMessageFormat());

    /// <summary>
    /// 短信验证码消息格式
    /// </summary>
    /// <returns></returns>
    public SettingItem<string> SmsCodeMessageFormat { get; set; } = new("ValidateCodeSetting:SmsCodeMessageFormat", GetSmsCodeMessageFormat());

    /// <summary>
    /// 邮件验证码消息格式
    /// </summary>
    /// <returns></returns>
    private static string GetEmailCodeMessageFormat()
    {
        return ResIdentity.String_Setting_EmailCodeMessageFormat;
        //return """
        //       <html>
        //       <body>
        //       <div>
        //         <h3>【{shortSiteName}】验证码邮件</h3>
        //         <p>尊敬的用户[{email}]：</p>
        //         <p>您好！</p>
        //         <p>您正在申请发送验证码：</p>
        //         <p style='font-size: 20px; font-weight: bold; color:orangered;'>{code}</p>
        //         <p>验证码在 {minutes} 分钟内有效，请尽快正确输入。</p>
        //         <p>验证码涉及个人账号隐私安全，切勿向他人透漏。</p>
        //         <p>如果不是您本人操作，请忽略此邮件。</p>
        //         <p>{companyName}</p>
        //       </div>
        //       </body>
        //       </html>
        //       """;
    }

    /// <summary>
    /// 短信验证码消息格式
    /// </summary>
    /// <returns></returns>
    private static string GetSmsCodeMessageFormat()
    {
        return ResIdentity.String_Setting_SmsCodeMessageFormat;
        //return """
        //       【{shortSiteName}】您的验证码为：{code}，{minutes}分钟内有效。如非本人操作，请忽略本短信。
        //       """;
    }
}
